package myhadoop;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;


/**
 * Reduce类,将key相同的合并起来，即收集过程。
 */
public class WordCountReduce extends Reducer<Text, IntWritable,Text,IntWritable> {
    public void reduce(Text key,Iterable<IntWritable> values,Context context) throws IOException, InterruptedException {
        int count=0;
        for (IntWritable value:values){
            count++;
        }
        context.write(key,new IntWritable(count));
    }
}
